//package com.base.data.elasticsearch.util;
//
//import lombok.extern.slf4j.Slf4j;
//import org.elasticsearch.action.search.SearchResponse;
//
//import java.util.Arrays;
//import java.util.List;
//import java.util.stream.Collectors;
//
//@Slf4j
//public class ResponseUtils {
//
//    public static <T> List<T> mapping(SearchResponse searchResponse, Class<T> clazz){
//        return Arrays.stream(searchResponse.getHits().getHits()).map(x-> {
//            String sourceString  =x.getSourceAsString();
//            return  GsonUtil.fromJson(sourceString,clazz);
//        }).collect(Collectors.toList());
//    }
//
//    public static <T> T mappingEntity(SearchResponse searchResponse, Class<T> clazz){
//        if(null==searchResponse.getHits())return null;
//        if(1!=searchResponse.getHits().getTotalHits()) throw new RuntimeException("searchEntity.hit morethan 1,please check query");
//        String sourceString  =searchResponse.getHits().getHits()[0].getSourceAsString();
//        return GsonUtil.fromJson(sourceString,clazz);
//    }
//
//}
